import { isNull, isString } from './typeof';

/** 清空 obj 的所有值 */
export function clearObj(obj: any) {
    if (isNull(obj)) {
        return;
    }

    for (const key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
            const element = obj[key];
            if (!isString(element)) {
                obj[key] = null;
            } else {
                obj[key] = '';
            }
        }
    }
}
